package com.usian.behavior.service.impl;

import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.usian.behavior.mapper.BehaviorEntryMapper;
import com.usian.behavior.service.BehaviorEntryService;
import com.usian.model.base.BaseServiceImpl;
import com.usian.model.behavior.pojos.ApBehaviorEntry;
import com.usian.model.common.dtos.ResponseResult;
import org.springframework.stereotype.Service;

@Service
public class BehaviorEntryServiceImpl extends BaseServiceImpl<BehaviorEntryMapper, ApBehaviorEntry> implements BehaviorEntryService {
    @Override
    public ResponseResult saveBehavior(ApBehaviorEntry apBehaviorEntry) {
        if (apBehaviorEntry == null) return paramError;
        save(apBehaviorEntry);
        return okResult;
    }

    @Override
    public ApBehaviorEntry findByUserIdOrEquipmentId(Integer userId) {
        if (userId == null) return null;
        return getOne(Wrappers.<ApBehaviorEntry>lambdaQuery().eq(ApBehaviorEntry::getEntryId, userId));
    }
}
